package com.atguigu.lease.web.admin.controller.agreement;

import com.atguigu.lease.common.result.Result;
import com.atguigu.lease.model.entity.LeaseAgreement;
import com.atguigu.lease.web.admin.dto.AgreementInfoSearchDto;
import com.atguigu.lease.web.admin.service.LeaseAgreementService;
import com.atguigu.lease.web.admin.vo.AgreementDetailsVo;
import com.atguigu.lease.web.admin.vo.AgreementInfoVo;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/agreement")
@Tag(name = "租约管理模块")
public class AgreementController {
    @Resource
    LeaseAgreementService leaseAgreementService;

    @Operation(summary = "条件分页查询租约列表")
    @GetMapping("page")
    public Result<Page<AgreementInfoVo>> page(AgreementInfoSearchDto searchDto){
        return Result.ok(leaseAgreementService.pageItem(searchDto));
    }
    @Operation(summary = "新增或更新租约信息")
    @PostMapping("saveOrUpdate")
    public Result saveOrUpdate(@RequestBody LeaseAgreement leaseAgreement){
        return Result.build(leaseAgreementService.saveOrUpdateAgreement(leaseAgreement));
    }
    @Operation(summary = "根据id查询租约详情")
    @GetMapping
    public Result<AgreementDetailsVo> getDetailsById(@RequestParam("id")Long id){
        return Result.ok(leaseAgreementService.getDetailsById(id));
    }

//    @Operation(summary = "根据id删除租约")
}
